Learn R Programming

optimbase (version 1.0-10)

zeros & ones: Matrix of zeros or ones.

Description

Creates a matrix of zeros or ones.

Usage

zeros(nx = 1, ny = nx)
  ones(nx = 1, ny = nx)

Arguments

nx

The number of rows. Default is 1.

ny

The number of columns. Default is nx.

Value

Return of nx x ny matrix of zeros of ones.

Details

zeros and ones create full matrices of zeros and ones. If the user only provides an input for nx, the produced matrices are nx x nx square matrices.

Examples

Run this code
# NOT RUN {
  zeros()
  zeros(3)
  ones(4,5)
  # Will fail
  try(ones('3','3'))
# }

Run the code above in your browser using DataLab